package com.xxhui.piedemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.xxhui.piedemo.View.PieChart;
import com.xxhui.piedemo.bean.PieData;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private PieChart chart ;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        chart = (PieChart) findViewById(R.id.pie_chart);
        chart.setData(getAutoData(6));
    }

    public List<PieData> getAutoData(int num){
        List<PieData> list = new ArrayList<PieData>();
        for(int i=0 ; i<num ; i++){
            PieData data = new PieData();
            data.setName(String.valueOf(i));
            data.setValue((float) Math.random()*100.0f);
            list.add(data);
        }
        return  list ;
    }
}
